# event for main menu
from Shell.fsm.EventDefine import event_MAINMENU
# skin
from Shell.gui.Skin import SkinGet
# gui
from Cube.gui.PreludeFinale import DropDownFrame
from direct.gui.DirectGui import DirectButton
from Cube.gui.QScrolledFrame import QScrolledTextLabelFrame
from Cube.gui.DirectGUIPropertiesAccess import BtnTextSet, BtnCmdSet
from Cube.gui.QSizer import ResizedCallBackSet, BoxSizer
from Cube.gui.DirectGUIPropertiesAccess import AlignText
# uiString
from Shell.data.UIString import uiString, uiStringScale


class CreatorFrame(DropDownFrame):
    def __init__(self):
        DropDownFrame.__init__(self)

        ParameterDict = SkinGet("Creator")

        param_textboard = ParameterDict["textboard"]
        param_sizerMain = ParameterDict["main sizer"]
        param_btn = ParameterDict["btn_Back"]
        param_btn["parent"] = self

        textBoardFrame = QScrolledTextLabelFrame(parent = self,
                                                 param_Label = param_textboard["Label"],
                                                 param_ScrolledFrame = param_textboard["ScrolledFrame"],
                                                 )

        btn_Back = DirectButton(**param_btn)

        BtnTextSet(btn_Back, uiString["Back"], param_btn["text_scale"])
        BtnCmdSet(btn_Back, messenger.send, [event_MAINMENU])

        sizeBtn = BoxSizer(BoxSizer.HORIZONTAL)
        sizeBtn.Add(BoxSizer(BoxSizer.VERTICAL),1)
        sizeBtn.Add(btn_Back,0)

        sizerMain = BoxSizer(BoxSizer.VERTICAL,
                             gap = param_sizerMain["gap"],
                             size = param_sizerMain["size"])
        sizerMain.Add(textBoardFrame,1)
        sizerMain.Add(sizeBtn,0)
        ResizedCallBackSet(btn_Back, AlignText, frame = btn_Back, align = "" )
        sizerMain.Layout()

        self.Prelude()
